package com.agileboot.domain.bot.conversationRecord.model;

import cn.hutool.core.bean.BeanUtil;
import com.agileboot.domain.bot.conversationRecord.command.AddConversationRecordCommand;
import com.agileboot.domain.bot.conversationRecord.command.UpdateConversationRecordCommand;
import com.agileboot.domain.bot.conversationRecord.db.ConversationRecordEntity;
import com.agileboot.domain.bot.conversationRecord.db.ConversationRecordService;
import lombok.NoArgsConstructor;

/**
 * 会话记录模型
 */
@NoArgsConstructor
public class ConversationRecordModel extends ConversationRecordEntity {

    private ConversationRecordService conversationRecordService;

    public ConversationRecordModel(ConversationRecordService service) {
        this.conversationRecordService = service;
    }

    public ConversationRecordModel(ConversationRecordEntity entity, ConversationRecordService service) {
        if (entity != null) {
            BeanUtil.copyProperties(entity, this);
        }
        this.conversationRecordService = service;
    }

    public void loadFromAddCommand(AddConversationRecordCommand command) {
        if (command != null) {
            BeanUtil.copyProperties(command, this, "id");
        }
    }

    public void loadFromUpdateCommand(UpdateConversationRecordCommand command) {
        if (command != null) {
            loadFromAddCommand(command);
        }
    }
}
